#!/usr/bin/env bash
#!/usr/bin/env bash

ip=`ifconfig eth0|grep inet|grep -v 127.0.0.1|grep -v inet6|awk '{print $2}'|tr -d "addr:"`
hn=`cat /etc/hostname`
echo $ip
echo $hn

service httpd stop
# 清除之前运行数据
# docker ps -a  |awk '{print $1}'|xargs docker rm
# docker images |grep "<none>"  |awk '{print $3}'|xargs docker rmi
docker ps -a|grep Exited |awk '{print $1}'|xargs docker rm >/dev/null 2>&1
# 启动php
#docker run --name nginx80 \
#-d -v /home/wolferhua/workspace/dockers/nginx/conf:/etc/nginx \
#-v /home/wolferhua/workspace/php:/home/wolferhua/workspace/php \
#-p 80:80 \
#nginx

docker ps -a|grep php56 |awk '{print $1}'|xargs docker stop >/dev/null 2>&1
docker ps -a|grep php56 |awk '{print $1}'|xargs docker rm >/dev/null 2>&1
# php 5.6
docker run -d \
--name php56 \
-d -v ~/dockers/bbsold/php56/etc:/usr/local/etc \
-v /www:/www \
--add-host=bbs.yingxiong.com:$ip \
--log-driver=json-file \
--log-opt max-size=10m \
--log-opt max-file=100 \
--restart=always \
 wolferhua/php:5.6-fpm
 



# docker run -it wolferhua/php:7.1-fpm-root


docker ps -a|grep nginx80 |awk '{print $1}'|xargs docker stop >/dev/null 2>&1
docker ps -a|grep nginx80 |awk '{print $1}'|xargs docker rm >/dev/null 2>&1
# 启动nginx
docker run --name nginx80 \
--link php56:php56 \
-d \
-v ~/dockers/bbsold/nginx/conf:/etc/nginx \
-v /www:/www \
-p 80:80 \
-p 443:443 \
--add-host=bbs.yingxiong.com:$ip \
--log-driver=json-file \
--log-opt max-size=10m \
--log-opt max-file=100 \
--restart=always \
wolferhua/nginx:1.13.6


chmod 0777 -Rf /www/web/kf/Runtime/
chmod 0777 -Rf /www/web/spass/Application/Runtime/
chmod 0777 -Rf /www/web/gamebbs/Runtime/
chmod 0777 -Rf /www/web/gamebbs/public_html/html/
chmod 0777 -Rf /www/web/club/public_html/runtime/


#docker run -d \
#--name apache56 \
#-d -v ~/dockers/bbsold/apache56/php/etc:/usr/local/etc \
#-d -v ~/dockers/bbsold/apache56/apache2:/etc/apache2  \
#-v ~/workspace/php:/www \
# wolferhua/php:5.6-apache
# hosts
#docker cp  /etc/hosts php71:/etc/hosts
